<template>
  <ul class="tab-bar">
    <li
    v-for="(route, index) in tabRoutes"
    :key="route.path"
    :class="{active: currentIndex === index}"
    @click="jump(route.path, index)"
    >
      <i class="iconfont" v-html="route.meta.icon"></i>
      <span>{{route.meta.title}}</span>
    </li>
  </ul>
</template>

<script>
import routes from '@/router/routes'
export default {
  name: 'Tabbar',
  data () {
    return {
      currentIndex: 0
    }
  },
  computed: {
    tabRoutes () {
      return routes.filter(route => route.meta && route.meta.isTab)
    }
  },
  methods: {
    jump (path, index) {
      this.currentIndex = index
      this.$router.push(path).catch(() => {})
    }
  }
}
</script>

<style lang="less">
@font-face {
  font-family: "iconfont"; /* project id 2409322 */
  src: url("//at.alicdn.com/t/font_2409322_9t1idtbplc.eot");
  src: url("//at.alicdn.com/t/font_2409322_9t1idtbplc.eot?#iefix")
      format("embedded-opentype"),
    url("//at.alicdn.com/t/font_2409322_9t1idtbplc.woff2") format("woff2"),
    url("//at.alicdn.com/t/font_2409322_9t1idtbplc.woff") format("woff"),
    url("//at.alicdn.com/t/font_2409322_9t1idtbplc.ttf") format("truetype"),
    url("//at.alicdn.com/t/font_2409322_9t1idtbplc.svg#iconfont") format("svg");
}
.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: 0.2px;
  -moz-osx-font-smoothing: grayscale;
}
.tab-bar {
  display: flex;
  border-top: 1px solid #eaeaea;
  li {
    flex: 1;
    height: 58px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    i {
      font-size: 24px;
    }
    &.active {
      color: #d81e06;
      font-weight: 700;
    }
  }
}
</style>
